package com.wc.AlgoOJ_homework.AlgoOJ_BL1.I_公因数匹配;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/30 11:48
 * @description http://43.138.190.70:8888/p/1097?tid=65f926e1f748afd09501f854
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010, M = 1000010;
    static int[] a = new int[N];
    // 存储最先出现的位置
    static int[] b = new int[M * 10];
    static boolean[] st = new boolean[M];
    static int[] primes = new int[M / 3];
    static int idx = 0;
    static int n;

    static void ola() {
        st[0] = st[1] = true;
        for (int i = 2; i < M; i++) {
            if (!st[i]) primes[++idx] = i;
            for (int j = 1; primes[j] * i < M; j++) {
                st[primes[j] * i] = true;
                if (i % primes[j] == 0) break;
            }
        }
    }

    public static void main(String[] args) {
        ola();
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();

        int minIdx = n + 1, maxIdx = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; primes[j] <= a[i] && j <= idx; j++) {
                if (a[i] % primes[j] == 0) {
                    if (b[primes[j]] != 0 && minIdx > b[primes[j]]) {
                        minIdx = b[primes[j]];
                        maxIdx = i;
                    }
                    if (b[primes[j]] == 0) b[primes[j]] = i;
                    while (a[i] % primes[j] == 0) a[i] /= primes[j];
                }
                if (!st[a[i]]) {
                    if (b[a[i]] != 0 && minIdx > b[a[i]]) {
                        minIdx = b[a[i]];
                        maxIdx = i;
                    }
                    if (b[a[i]] == 0) b[a[i]] = i;
                    break;
                }
            }
        }
        out.println(minIdx + " " + maxIdx);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
